Quickstart React Native
This guide will help you to implement the Group Link Mobile SDK on your application written for the React Native framework.
Step 1 - Installing the SDK
Inside your project root folder paste one of the following lines on your terminal.
npm i @grouplinknetwork/rn-grouplink-sdk
yarn add @grouplinknetwork/rn-grouplink-sdk
Step 2 - Setup the SDK
You will need to add the required permissions to your Android manifest file (android/app/src folder) and your info.plist file (you can find this file inside the ios folder). You can follow the Android Required Permissions and iOS Required Permissions guide to learn more.
If you configure the native files through your app.json, add these permissions:
"android":{
"permissions": [
"INTERNET",
"ACCESS_FINE_LOCATION",
"ACCESS_COARSE_LOCATION",
"BLUETOOTH_ADMIN",
"ACCESS_WIFI_STATE",
"FOREGROUND_SERVICE",
"BLUETOOTH_SCAN",
"BLUETOOTH_ADVERTISE",
"BLUETOOTH_CONNECT",
"POST_NOTIFICATIONS"
]
}
"ios": {
"infoPlist": {
"NSBluetoothAlwaysUsageDescription": "We need bluetooth permission for a better user experience",
"NSBluetoothPeripheralUsageDescription": "We need bluetooth permission for a better user experience",
"NSLocationAlwaysAndWhenInUseUsageDescription": "We need location permission for a better user experience",
"NSLocationWhenInUseUsageDescription": "We need location permission for a better user experience",
"UIBackgroundModes": [
"bluetooth-peripheral",
"location",
"bluetooth-central",
"processing",
"fetch"
],
"BGTaskSchedulerPermittedIdentifiers": [
"com.grouplinknetwork.bgtask"
]
}
}
Step 3 - Setup the SDK
To initialize our SDK for both Android and iOS platforms, you can use the following approach:
import * as GroupLinkSDK from '@grouplinknetwork/rn-grouplink-sdk';
export default function App() {
useEffect(()=>{
// This function requires the Group Link Token from your organization and
// accepts a boolean value to determine its debuggability.
GroupLinkSDK.startGrouplink("GROUP_LINK_TOKEN", isDebuggable);
},[])
return (
<View style={styles.container}>
<Text>This is a test app</Text>
</View>
);
}
We automatically detect the platform you're using and invoke the appropriate methods for SDK initialization.
However, if you'd like to initialize the SDK on a single platform, you can use the following method:
For iOS -
import * as GroupLinkSDK from '@grouplinknetwork/rn-grouplink-sdk';
export default function App() {
useEffect(()=>{
// This function requires the Group Link Token from your organization.
GroupLinkSDK.startGrouplinkIOS("GROUP_LINK_TOKEN");
},[])
return (
<View style={styles.container}>
<Text>This is a test app</Text>
</View>
);
}
For Android -
import * as GroupLinkSDK from '@grouplinknetwork/rn-grouplink-sdk';
export default function App() {
useEffect(()=>{
// This function requires the Group Link Token from your organization and
// accepts a boolean value to determine its debuggability.
GroupLinkSDK.startGrouplinkAndroid("GROUP_LINK_TOKEN", isDebuggable);
},[])
return (
<View style={styles.container}>
<Text>This is a test app</Text>
</View>
);
}
Next Steps
Now that you have successfully initialized the Group Link SDK inside your app, you have to follow the iOS and Android specific code.